package com.lmb.controller;

import com.lmb.bean.ResidentEmergencies;
import com.lmb.mapper.ResidentEmergenciesDao;
import com.lmb.service.ResidentEmergenciesService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/residentEmergencies")
public class ResidentEmergenciesController {
    @Autowired
    ResidentEmergenciesDao residentEmergenciesDao;
    @Autowired
    ResidentEmergenciesService residentEmergenciesService;
    @PostMapping
    public Result add(@RequestBody ResidentEmergencies residentEmergencies)
    {
        Object obj=residentEmergenciesService.add(residentEmergencies);
        return Result.success(obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=residentEmergenciesService.del(id);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody ResidentEmergencies residentEmergencies){
        System.out.println(residentEmergencies);
        Object obj=residentEmergenciesService.edit(residentEmergencies);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all( ResidentEmergencies residentEmergencies){
        Object obj=residentEmergenciesService.all(residentEmergencies);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=residentEmergenciesService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, ResidentEmergencies residentEmergencies){
        residentEmergenciesService.page(page,residentEmergencies);
        return Result.success(page);
    }
}
